package main

import (
	"context"
	"fmt"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)

type Group struct {
	_Id  string
	Id   int64
	Name string
	Desc string
}

func main() {
	client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://192.168.12.21:27017?minPoolSize=10&maxIdleTimeMS=10000"))
	if err != nil {
		return
	}
	c := client.Database("tia_comics_group").Collection("group_0")
	ctx := context.Background()
	client.Connect(ctx)
	result, err := c.Find(nil, bson.M{"_id": "12#g_tias"})
	fmt.Println(err)
	fmt.Println(result)

	for result.Next(ctx) {
		//var group = make(map[string]interface{})
		var group = &Group{}
		result.Decode(&group)
		fmt.Println(group)
	}
}

func printElement(e bson.RawElement) {
	fmt.Print(e.Key() + " : ")
	e.Value()
}
